import {m as n} from "./mitt.f0e547641729265196717.js";

const r = n(), e = {id: "id", children: "children", pid: "pid"}, t = n => Object.assign({}, e, n), i = (n, r = {}) => {
    r = t(r);
    const {children: e} = r, i = [...n];
    for (let t = 0; t < i.length; t++) i[t][e] && i.splice(t + 1, 0, ...i[t][e]);
    return i
}, s = (n, r, e = {}) => {
    e = t(e);
    const i = [], s = [...n], c = new Set, {children: l} = e;
    for (; s.length;) {
        const n = s[0];
        if (c.has(n)) i.pop(), s.shift(); else if (c.add(n), n[l] && s.unshift(...n[l]), i.push(n), r(n)) return i
    }
    return null
}, c = (n, r, e = {}) => {
    const i = (e = t(e)).children;
    return function n(e) {
        return e.map((n => ({...n}))).filter((e => (e[i] = e[i] && n(e[i]), r(e) || e[i] && e[i].length)))
    }(n)
}, l = (n, r) => n.map((n => h(n, r))), h = (n, {children: r = "children", conversion: e}) => {
    const t = Array.isArray(n[r]) && n[r].length > 0, i = e(n) || {};
    return t ? {...i, [r]: n[r].map((n => h(n, {children: r, conversion: e})))} : {...i}
}, o = (n, r, e = {}) => {
    n.forEach((n => {
        const t = r(n, e) || n;
        n.children && o(n.children, r, t)
    }))
};
export {s as a, r as b, i as c, o as e, c as f, l as t};
